
package cup.modules.visual.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import cup.core.boot.ctrl.CupController;
import cup.core.mp.support.Condition;
import cup.core.mp.support.Query;
import cup.core.oss.MinioTemplate;
import cup.core.oss.model.CupFile;
import cup.core.tool.api.R;
import cup.core.tool.support.Kv;
import cup.core.tool.utils.Func;
import cup.core.tool.utils.ObjectUtil;
import cup.modules.visual.constant.LauncherConstant;
import cup.modules.visual.dto.VisualDTO;
import cup.modules.visual.entity.Visual;
import cup.modules.visual.entity.VisualCategory;
import cup.modules.visual.entity.VisualChart;
import cup.modules.visual.log.DataLog;
import cup.modules.visual.service.IVisualCategoryService;
import cup.modules.visual.service.IVisualChartService;
import cup.modules.visual.service.IVisualService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.java.Log;
import lombok.val;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 可视化图标管理 控制器
 *
 * @author haisheng.mao
 */
@RestController
@AllArgsConstructor
@RequestMapping(LauncherConstant.APPLICATION_VISUAL_NAME+"/visualChart")
@Api(value = "可视化图标管理", tags = "可视化图标管理")
public class VisualChartController extends CupController {

	private final IVisualChartService  service;

	@ApiOperation("新增/修改图表信息")
	@PutMapping("save")
	public void save(@RequestBody VisualChart entity) {
		service.save(entity);
	}

	@ApiOperation("图表查询")
	@GetMapping("all")
	public List<VisualChart> queryChart(Query query,VisualChart req) {
		query.setSize(Integer.MAX_VALUE);
		return service.findByPage(Condition.getPage(query),req).getRecords();
	}

	@ApiOperation("图表详情JSON")
	@GetMapping("get")
	public VisualChart get(@RequestParam("id") String id) {
		return service.findById(id);
	}

	@ApiOperation("删除图表信息")
	@DeleteMapping("delete/{primaryKey}")
	public void remove(@PathVariable(name = "primaryKey") String primaryKey) {
		service.deleteById(primaryKey);
	}

	@ApiOperation("删除图表信息list")
	@DeleteMapping("delete")
	public void deleteByIdIn(@RequestBody List<String> ids) {
		service.deleteByIdIn(ids);
	}

	@ApiOperation("分页查询图表数据")
	@GetMapping("page")
	public IPage<VisualChart> getChartByPage(Query query,VisualChart req) {
		return service.findByPage(Condition.getPage(query),req);
	}

}
